#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int N, M, H, T;
vector<int> edges[101010];
vector<pair<int,int> > vec;

vector<int> heads, tails, comp;
bool hydra(int a, int b) {
  if (((int)edges[a].size() + edges[b].size())-2 < H + T) return false;
  int i1 = 0, i2 = 0;
  if (edges[a].size() < min(H,T)+1) return false;
  if (edges[b].size() < min(H,T)+1) return false;
  heads.clear(), tails.clear(), comp.clear();
  while (i1 < edges[a].size() or i2 < edges[b].size()) {
    if (i1 == edges[a].size()) {
      if (edges[b][i2] != a) heads.push_back(edges[b][i2]);
      i2++;
    } else if (i2 == edges[b].size()) {
      if (edges[a][i1] !=  b) tails.push_back(edges[a][i1]);
      i1++;
    } else {
      if (edges[a][i1] < edges[b][i2]) {
        if (edges[a][i1] != b) tails.push_back(edges[a][i1]);
        i1++;
      } else if (edges[a][i1] > edges[b][i2]) {
        if (edges[b][i2] != a) heads.push_back(edges[b][i2]);
        i2++;
      } else {
        comp.push_back(edges[a][i1]);
        i1++,i2++;
      }
    }
  }
  int i3 = 0;
  while (i3 < comp.size() && (heads.size() < H or tails.size() < T)) {
    if (heads.size() < H) { heads.push_back(comp[i3]); i3++;}
    else if (tails.size() < T) { tails.push_back(comp[i3]); i3++;}
  }
  if (heads.size() >= H && tails.size() >= T) return true;
  return false;
}

int main() {
  int i,j , k;
  scanf("%d %d %d %d", &N, &M, &H, &T);
  int change = 0;
  if (H < T) swap(H,T), change = 1;
  for (i = 0; i < M; ++i) {
    int a, b; scanf("%d %d", &a, &b);
    a--,b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    vec.push_back(make_pair(a,b));
  }
  for (i = 0; i < N; ++i) sort(edges[i].begin(), edges[i].end());

  for (i = 0; i < vec.size(); ++i) {
    // para cada arista, vemos si its okkk...
    int a = vec[i].first;
    int b = vec[i].second;
    if (edges[a].size() > edges[b].size()) swap(a,b);
    if (hydra(a,b)) {
      printf("YES\n");
      if (change) { swap(a,b); swap(heads, tails); swap(H,T);}
      printf("%d %d\n", b+1, a+1);
      for (j = 0; j < H; ++j) {
        if (j) printf(" ");
        printf("%d", 1+heads[j]);
      } printf("\n");
      for (j = 0; j < T; ++j) {
        if (j) printf(" ");
        printf("%d", 1+tails[j]);
      } printf("\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}

